home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-09-25 | 2.6 KB | 116 lines | [TEXT/CWIE] |
- // ===========================================================================
- // LDynamicArray.h ©1994-1996 Metrowerks Inc. All rights reserved.
- // ===========================================================================
- //
- // An ordered collection of fixed-size items. Positions in the Array are
- // one-based--the first item is at index 1.
-
- #ifndef _H_LDynamicArray
- #define _H_LDynamicArray
- #pragma once
-
- #include <PP_Prefix.h>
-
- typedef Int32 ArrayIndexT;
-
-
- class LDynamicArray {
- public:
- enum { index_Bad = 0,
- index_First = 1,
- index_Last = 0x7FFFFFFF };
-
- LDynamicArray(
- Uint32 inItemSize,
- Uint32 inSpaces = 0);
- LDynamicArray(
- Uint32 inItemSize,
- Handle inItemsHandle);
- virtual ~LDynamicArray();
-
- Boolean ValidIndex(
- ArrayIndexT &inIndex) const;
-
- Uint32 GetItemSize() const { return mItemSize; }
- Uint32 GetCount() const { return mItemCount; }
-
- virtual void InsertItemsAt(
- Uint32 inCount,
- ArrayIndexT inAtIndex,
- const void *inItem);
-
- virtual void RemoveItemsAt(
- Uint32 inCount,
- ArrayIndexT inAtIndex);
-
- virtual Boolean FetchItemAt(
- ArrayIndexT inAtIndex,
- void *outItem) const;
-
- virtual void AssignItemsAt(
- Uint32 inCount,
- ArrayIndexT inAtIndex,
- const void *inValue);
-
- virtual void SetItemAt(
- ArrayIndexT inAtIndex,
- const void *inItem);
-
- virtual void SwapItems(
- ArrayIndexT inIndexA,
- ArrayIndexT inIndexB);
- virtual void MoveItem(
- ArrayIndexT inFromIndex,
- ArrayIndexT inToIndex);
-
- virtual ArrayIndexT FetchIndexOf(
- const void *inItem) const;
-
- virtual void Remove(
- const void *inItem);
-
- void Lock();
- void Unlock();
- virtual void* GetItemPtr(
- ArrayIndexT inAtIndex) const;
-
- void AllocateSpace(
- Uint32 inSpaces);
-
- protected:
- Uint32 mItemSize;
- Uint32 mItemCount;
- Uint32 mAllocation;
- Handle mItemsH;
- Uint32 mLockCount;
-
- void PeekItem(
- ArrayIndexT inAtIndex,
- void *outItem) const
- {
- ::BlockMoveData(GetItemPtr(inAtIndex), outItem,
- mItemSize);
- }
-
- void PokeItem(
- ArrayIndexT inAtIndex,
- const void *inItem)
- {
- ::BlockMoveData(inItem, GetItemPtr(inAtIndex),
- mItemSize);
- }
-
- void ShiftItems(
- ArrayIndexT inStartPos,
- ArrayIndexT inEndPos,
- ArrayIndexT inDestPos);
- };
-
- #ifndef _H_LList
- const Int32 arrayIndex_Bad = 0;
- const Int32 arrayIndex_First = 1;
- const Int32 arrayIndex_Last = 0x7FFFFFFF;
- #endif
-
- #endif
-